# Maintainer: umarcor <unai.martinezcorral@ehu.eus>

_realname=openFPGALoader
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2.1
pkgrel=1
pkgdesc="openFPGALoader: universal utility for programming FPGA (mingw-w64)"
arch=('any')
url="https://github.com/trabucayre/openFPGALoader"
license=('AGPLv3.0')
groups=("${MINGW_PACKAGE_PREFIX}-eda")
depends=("${MINGW_PACKAGE_PREFIX}-libftdi")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-gcc"
  "${MINGW_PACKAGE_PREFIX}-cmake"
)

source=("${_realname}::https://codeload.github.com/trabucayre/openFPGALoader/tar.gz/v${pkgver}")
sha256sums=('b0baa1f696007dc1bb4e1d7c5eaab3bfa13230821e51743dded7cfcc7ddb6431')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  mkdir build
  cd build
  MSYS2_ARG_CONV_EXCL=- cmake \
    -G "MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    ../
  cmake --build .
}

check() {
  "${srcdir}/${_realname}-${pkgver}"/build/openFPGALoader.exe --help
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"/build
  make DESTDIR="${pkgdir}" install

  _licenses="${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
  mkdir -p "${_licenses}"
  install -m 644 "${srcdir}/${_realname}-${pkgver}"/LICENSE "${_licenses}"
}
